import React, { Component } from 'react';

//作为模板配置中的插槽使用，方便迅速把配置信息插入到模板中
export default class Slot extends Component {
  //将children信息转化为对象

  static parseChild(child) {
    if (!child) {
      return {};
    }
    let slotObj = {};
    React.Children.map(child, (slot) => {
      if (slot.type == Slot && slot.props.name) {
        const { Children, ...props } = slot.props;
        slotObj[slot.props.name] = { Children, props };
      }
    });
    return slotObj;
  }

  render() {
    return null;
  }
}
